// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.MachineLearning;

public sealed partial class PutDataFrameAnalyticsRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>Instantiates a data frame analytics job.<br/>This API creates a data frame analytics job that performs an analysis on the<br/>source indices and stores the outcome in a destination index.</para>
/// </summary>
public sealed partial class PutDataFrameAnalyticsRequest : PlainRequest<PutDataFrameAnalyticsRequestParameters>
{
	public PutDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("id", id))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutDataFrameAnalytics;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_data_frame_analytics";

	/// <summary>
	/// <para>Specifies whether this job can start when there is insufficient machine<br/>learning node capacity for it to be immediately assigned to a node. If<br/>set to `false` and a machine learning node with capacity to run the job<br/>cannot be immediately found, the API returns an error. If set to `true`,<br/>the API does not return an error; the job waits in the `starting` state<br/>until sufficient machine learning node capacity is available. This<br/>behavior is also affected by the cluster-wide<br/>`xpack.ml.max_lazy_ml_nodes` setting.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("allow_lazy_start")]
	public bool? AllowLazyStart { get; set; }

	/// <summary>
	/// <para>The analysis configuration, which contains the information necessary to<br/>perform one of the following types of analysis: classification, outlier<br/>detection, or regression.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("analysis")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis Analysis { get; set; }

	/// <summary>
	/// <para>Specifies `includes` and/or `excludes` patterns to select which fields<br/>will be included in the analysis. The patterns specified in `excludes`<br/>are applied last, therefore `excludes` takes precedence. In other words,<br/>if the same field is specified in both `includes` and `excludes`, then<br/>the field will not be included in the analysis. If `analyzed_fields` is<br/>not set, only the relevant fields will be included. For example, all the<br/>numeric fields for outlier detection.<br/>The supported fields vary for each type of analysis. Outlier detection<br/>requires numeric or `boolean` data to analyze. The algorithms don’t<br/>support missing values therefore fields that have data types other than<br/>numeric or boolean are ignored. Documents where included fields contain<br/>missing values, null values, or an array are also ignored. Therefore the<br/>`dest` index may contain documents that don’t have an outlier score.<br/>Regression supports fields that are numeric, `boolean`, `text`,<br/>`keyword`, and `ip` data types. It is also tolerant of missing values.<br/>Fields that are supported are included in the analysis, other fields are<br/>ignored. Documents where included fields contain an array with two or<br/>more values are also ignored. Documents in the `dest` index that don’t<br/>contain a results field are not included in the regression analysis.<br/>Classification supports fields that are numeric, `boolean`, `text`,<br/>`keyword`, and `ip` data types. It is also tolerant of missing values.<br/>Fields that are supported are included in the analysis, other fields are<br/>ignored. Documents where included fields contain an array with two or<br/>more values are also ignored. Documents in the `dest` index that don’t<br/>contain a results field are not included in the classification analysis.<br/>Classification analysis can be improved by mapping ordinal variable<br/>values to a single number. For example, in case of age ranges, you can<br/>model the values as `0-14 = 0`, `15-24 = 1`, `25-34 = 2`, and so on.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("analyzed_fields")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; set; }

	/// <summary>
	/// <para>A description of the job.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }

	/// <summary>
	/// <para>The destination configuration.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("dest")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination Dest { get; set; }
	[JsonInclude, JsonPropertyName("headers")]
	public IDictionary<string, Union<string, ICollection<string>>>? Headers { get; set; }

	/// <summary>
	/// <para>The maximum number of threads to be used by the analysis. Using more<br/>threads may decrease the time necessary to complete the analysis at the<br/>cost of using more CPU. Note that the process may use additional threads<br/>for operational functionality other than the analysis itself.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("max_num_threads")]
	public int? MaxNumThreads { get; set; }

	/// <summary>
	/// <para>The approximate maximum amount of memory resources that are permitted for<br/>analytical processing. If your `elasticsearch.yml` file contains an<br/>`xpack.ml.max_model_memory_limit` setting, an error occurs when you try<br/>to create data frame analytics jobs that have `model_memory_limit` values<br/>greater than that setting.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("model_memory_limit")]
	public string? ModelMemoryLimit { get; set; }

	/// <summary>
	/// <para>The configuration of how to source the analysis data.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("source")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource Source { get; set; }
	[JsonInclude, JsonPropertyName("version")]
	public string? Version { get; set; }
}

/// <summary>
/// <para>Instantiates a data frame analytics job.<br/>This API creates a data frame analytics job that performs an analysis on the<br/>source indices and stores the outcome in a destination index.</para>
/// </summary>
public sealed partial class PutDataFrameAnalyticsRequestDescriptor<TDocument> : RequestDescriptor<PutDataFrameAnalyticsRequestDescriptor<TDocument>, PutDataFrameAnalyticsRequestParameters>
{
	internal PutDataFrameAnalyticsRequestDescriptor(Action<PutDataFrameAnalyticsRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

	public PutDataFrameAnalyticsRequestDescriptor(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("id", id))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutDataFrameAnalytics;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_data_frame_analytics";

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Id(Elastic.Clients.Elasticsearch.Id id)
	{
		RouteValues.Required("id", id);
		return Self;
	}

	private bool? AllowLazyStartValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis AnalysisValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor<TDocument> AnalysisDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor<TDocument>> AnalysisDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFieldsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor AnalyzedFieldsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor> AnalyzedFieldsDescriptorAction { get; set; }
	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination DestValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor<TDocument> DestDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor<TDocument>> DestDescriptorAction { get; set; }
	private IDictionary<string, Union<string, ICollection<string>>>? HeadersValue { get; set; }
	private int? MaxNumThreadsValue { get; set; }
	private string? ModelMemoryLimitValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource SourceValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor<TDocument> SourceDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor<TDocument>> SourceDescriptorAction { get; set; }
	private string? VersionValue { get; set; }

	/// <summary>
	/// <para>Specifies whether this job can start when there is insufficient machine<br/>learning node capacity for it to be immediately assigned to a node. If<br/>set to `false` and a machine learning node with capacity to run the job<br/>cannot be immediately found, the API returns an error. If set to `true`,<br/>the API does not return an error; the job waits in the `starting` state<br/>until sufficient machine learning node capacity is available. This<br/>behavior is also affected by the cluster-wide<br/>`xpack.ml.max_lazy_ml_nodes` setting.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> AllowLazyStart(bool? allowLazyStart = true)
	{
		AllowLazyStartValue = allowLazyStart;
		return Self;
	}

	/// <summary>
	/// <para>The analysis configuration, which contains the information necessary to<br/>perform one of the following types of analysis: classification, outlier<br/>detection, or regression.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Analysis(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis analysis)
	{
		AnalysisDescriptor = null;
		AnalysisDescriptorAction = null;
		AnalysisValue = analysis;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Analysis(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor<TDocument> descriptor)
	{
		AnalysisValue = null;
		AnalysisDescriptorAction = null;
		AnalysisDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Analysis(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor<TDocument>> configure)
	{
		AnalysisValue = null;
		AnalysisDescriptor = null;
		AnalysisDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>Specifies `includes` and/or `excludes` patterns to select which fields<br/>will be included in the analysis. The patterns specified in `excludes`<br/>are applied last, therefore `excludes` takes precedence. In other words,<br/>if the same field is specified in both `includes` and `excludes`, then<br/>the field will not be included in the analysis. If `analyzed_fields` is<br/>not set, only the relevant fields will be included. For example, all the<br/>numeric fields for outlier detection.<br/>The supported fields vary for each type of analysis. Outlier detection<br/>requires numeric or `boolean` data to analyze. The algorithms don’t<br/>support missing values therefore fields that have data types other than<br/>numeric or boolean are ignored. Documents where included fields contain<br/>missing values, null values, or an array are also ignored. Therefore the<br/>`dest` index may contain documents that don’t have an outlier score.<br/>Regression supports fields that are numeric, `boolean`, `text`,<br/>`keyword`, and `ip` data types. It is also tolerant of missing values.<br/>Fields that are supported are included in the analysis, other fields are<br/>ignored. Documents where included fields contain an array with two or<br/>more values are also ignored. Documents in the `dest` index that don’t<br/>contain a results field are not included in the regression analysis.<br/>Classification supports fields that are numeric, `boolean`, `text`,<br/>`keyword`, and `ip` data types. It is also tolerant of missing values.<br/>Fields that are supported are included in the analysis, other fields are<br/>ignored. Documents where included fields contain an array with two or<br/>more values are also ignored. Documents in the `dest` index that don’t<br/>contain a results field are not included in the classification analysis.<br/>Classification analysis can be improved by mapping ordinal variable<br/>values to a single number. For example, in case of age ranges, you can<br/>model the values as `0-14 = 0`, `15-24 = 1`, `25-34 = 2`, and so on.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> AnalyzedFields(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? analyzedFields)
	{
		AnalyzedFieldsDescriptor = null;
		AnalyzedFieldsDescriptorAction = null;
		AnalyzedFieldsValue = analyzedFields;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> AnalyzedFields(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor descriptor)
	{
		AnalyzedFieldsValue = null;
		AnalyzedFieldsDescriptorAction = null;
		AnalyzedFieldsDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> AnalyzedFields(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor> configure)
	{
		AnalyzedFieldsValue = null;
		AnalyzedFieldsDescriptor = null;
		AnalyzedFieldsDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>A description of the job.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>The destination configuration.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Dest(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination dest)
	{
		DestDescriptor = null;
		DestDescriptorAction = null;
		DestValue = dest;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Dest(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor<TDocument> descriptor)
	{
		DestValue = null;
		DestDescriptorAction = null;
		DestDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Dest(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor<TDocument>> configure)
	{
		DestValue = null;
		DestDescriptor = null;
		DestDescriptorAction = configure;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Headers(Func<FluentDictionary<string, Union<string, ICollection<string>>>, FluentDictionary<string, Union<string, ICollection<string>>>> selector)
	{
		HeadersValue = selector?.Invoke(new FluentDictionary<string, Union<string, ICollection<string>>>());
		return Self;
	}

	/// <summary>
	/// <para>The maximum number of threads to be used by the analysis. Using more<br/>threads may decrease the time necessary to complete the analysis at the<br/>cost of using more CPU. Note that the process may use additional threads<br/>for operational functionality other than the analysis itself.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> MaxNumThreads(int? maxNumThreads)
	{
		MaxNumThreadsValue = maxNumThreads;
		return Self;
	}

	/// <summary>
	/// <para>The approximate maximum amount of memory resources that are permitted for<br/>analytical processing. If your `elasticsearch.yml` file contains an<br/>`xpack.ml.max_model_memory_limit` setting, an error occurs when you try<br/>to create data frame analytics jobs that have `model_memory_limit` values<br/>greater than that setting.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> ModelMemoryLimit(string? modelMemoryLimit)
	{
		ModelMemoryLimitValue = modelMemoryLimit;
		return Self;
	}

	/// <summary>
	/// <para>The configuration of how to source the analysis data.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Source(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource source)
	{
		SourceDescriptor = null;
		SourceDescriptorAction = null;
		SourceValue = source;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Source(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor<TDocument> descriptor)
	{
		SourceValue = null;
		SourceDescriptorAction = null;
		SourceDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Source(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor<TDocument>> configure)
	{
		SourceValue = null;
		SourceDescriptor = null;
		SourceDescriptorAction = configure;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor<TDocument> Version(string? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowLazyStartValue.HasValue)
		{
			writer.WritePropertyName("allow_lazy_start");
			writer.WriteBooleanValue(AllowLazyStartValue.Value);
		}

		if (AnalysisDescriptor is not null)
		{
			writer.WritePropertyName("analysis");
			JsonSerializer.Serialize(writer, AnalysisDescriptor, options);
		}
		else if (AnalysisDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor<TDocument>(AnalysisDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("analysis");
			JsonSerializer.Serialize(writer, AnalysisValue, options);
		}

		if (AnalyzedFieldsDescriptor is not null)
		{
			writer.WritePropertyName("analyzed_fields");
			JsonSerializer.Serialize(writer, AnalyzedFieldsDescriptor, options);
		}
		else if (AnalyzedFieldsDescriptorAction is not null)
		{
			writer.WritePropertyName("analyzed_fields");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor(AnalyzedFieldsDescriptorAction), options);
		}
		else if (AnalyzedFieldsValue is not null)
		{
			writer.WritePropertyName("analyzed_fields");
			JsonSerializer.Serialize(writer, AnalyzedFieldsValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (DestDescriptor is not null)
		{
			writer.WritePropertyName("dest");
			JsonSerializer.Serialize(writer, DestDescriptor, options);
		}
		else if (DestDescriptorAction is not null)
		{
			writer.WritePropertyName("dest");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor<TDocument>(DestDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("dest");
			JsonSerializer.Serialize(writer, DestValue, options);
		}

		if (HeadersValue is not null)
		{
			writer.WritePropertyName("headers");
			JsonSerializer.Serialize(writer, HeadersValue, options);
		}

		if (MaxNumThreadsValue.HasValue)
		{
			writer.WritePropertyName("max_num_threads");
			writer.WriteNumberValue(MaxNumThreadsValue.Value);
		}

		if (!string.IsNullOrEmpty(ModelMemoryLimitValue))
		{
			writer.WritePropertyName("model_memory_limit");
			writer.WriteStringValue(ModelMemoryLimitValue);
		}

		if (SourceDescriptor is not null)
		{
			writer.WritePropertyName("source");
			JsonSerializer.Serialize(writer, SourceDescriptor, options);
		}
		else if (SourceDescriptorAction is not null)
		{
			writer.WritePropertyName("source");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor<TDocument>(SourceDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("source");
			JsonSerializer.Serialize(writer, SourceValue, options);
		}

		if (!string.IsNullOrEmpty(VersionValue))
		{
			writer.WritePropertyName("version");
			writer.WriteStringValue(VersionValue);
		}

		writer.WriteEndObject();
	}
}

/// <summary>
/// <para>Instantiates a data frame analytics job.<br/>This API creates a data frame analytics job that performs an analysis on the<br/>source indices and stores the outcome in a destination index.</para>
/// </summary>
public sealed partial class PutDataFrameAnalyticsRequestDescriptor : RequestDescriptor<PutDataFrameAnalyticsRequestDescriptor, PutDataFrameAnalyticsRequestParameters>
{
	internal PutDataFrameAnalyticsRequestDescriptor(Action<PutDataFrameAnalyticsRequestDescriptor> configure) => configure.Invoke(this);

	public PutDataFrameAnalyticsRequestDescriptor(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("id", id))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutDataFrameAnalytics;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_data_frame_analytics";

	public PutDataFrameAnalyticsRequestDescriptor Id(Elastic.Clients.Elasticsearch.Id id)
	{
		RouteValues.Required("id", id);
		return Self;
	}

	private bool? AllowLazyStartValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis AnalysisValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor AnalysisDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor> AnalysisDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFieldsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor AnalyzedFieldsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor> AnalyzedFieldsDescriptorAction { get; set; }
	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination DestValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor DestDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor> DestDescriptorAction { get; set; }
	private IDictionary<string, Union<string, ICollection<string>>>? HeadersValue { get; set; }
	private int? MaxNumThreadsValue { get; set; }
	private string? ModelMemoryLimitValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource SourceValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor SourceDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor> SourceDescriptorAction { get; set; }
	private string? VersionValue { get; set; }

	/// <summary>
	/// <para>Specifies whether this job can start when there is insufficient machine<br/>learning node capacity for it to be immediately assigned to a node. If<br/>set to `false` and a machine learning node with capacity to run the job<br/>cannot be immediately found, the API returns an error. If set to `true`,<br/>the API does not return an error; the job waits in the `starting` state<br/>until sufficient machine learning node capacity is available. This<br/>behavior is also affected by the cluster-wide<br/>`xpack.ml.max_lazy_ml_nodes` setting.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor AllowLazyStart(bool? allowLazyStart = true)
	{
		AllowLazyStartValue = allowLazyStart;
		return Self;
	}

	/// <summary>
	/// <para>The analysis configuration, which contains the information necessary to<br/>perform one of the following types of analysis: classification, outlier<br/>detection, or regression.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor Analysis(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis analysis)
	{
		AnalysisDescriptor = null;
		AnalysisDescriptorAction = null;
		AnalysisValue = analysis;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Analysis(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor descriptor)
	{
		AnalysisValue = null;
		AnalysisDescriptorAction = null;
		AnalysisDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Analysis(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor> configure)
	{
		AnalysisValue = null;
		AnalysisDescriptor = null;
		AnalysisDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>Specifies `includes` and/or `excludes` patterns to select which fields<br/>will be included in the analysis. The patterns specified in `excludes`<br/>are applied last, therefore `excludes` takes precedence. In other words,<br/>if the same field is specified in both `includes` and `excludes`, then<br/>the field will not be included in the analysis. If `analyzed_fields` is<br/>not set, only the relevant fields will be included. For example, all the<br/>numeric fields for outlier detection.<br/>The supported fields vary for each type of analysis. Outlier detection<br/>requires numeric or `boolean` data to analyze. The algorithms don’t<br/>support missing values therefore fields that have data types other than<br/>numeric or boolean are ignored. Documents where included fields contain<br/>missing values, null values, or an array are also ignored. Therefore the<br/>`dest` index may contain documents that don’t have an outlier score.<br/>Regression supports fields that are numeric, `boolean`, `text`,<br/>`keyword`, and `ip` data types. It is also tolerant of missing values.<br/>Fields that are supported are included in the analysis, other fields are<br/>ignored. Documents where included fields contain an array with two or<br/>more values are also ignored. Documents in the `dest` index that don’t<br/>contain a results field are not included in the regression analysis.<br/>Classification supports fields that are numeric, `boolean`, `text`,<br/>`keyword`, and `ip` data types. It is also tolerant of missing values.<br/>Fields that are supported are included in the analysis, other fields are<br/>ignored. Documents where included fields contain an array with two or<br/>more values are also ignored. Documents in the `dest` index that don’t<br/>contain a results field are not included in the classification analysis.<br/>Classification analysis can be improved by mapping ordinal variable<br/>values to a single number. For example, in case of age ranges, you can<br/>model the values as `0-14 = 0`, `15-24 = 1`, `25-34 = 2`, and so on.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor AnalyzedFields(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? analyzedFields)
	{
		AnalyzedFieldsDescriptor = null;
		AnalyzedFieldsDescriptorAction = null;
		AnalyzedFieldsValue = analyzedFields;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor AnalyzedFields(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor descriptor)
	{
		AnalyzedFieldsValue = null;
		AnalyzedFieldsDescriptorAction = null;
		AnalyzedFieldsDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor AnalyzedFields(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor> configure)
	{
		AnalyzedFieldsValue = null;
		AnalyzedFieldsDescriptor = null;
		AnalyzedFieldsDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>A description of the job.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>The destination configuration.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor Dest(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination dest)
	{
		DestDescriptor = null;
		DestDescriptorAction = null;
		DestValue = dest;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Dest(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor descriptor)
	{
		DestValue = null;
		DestDescriptorAction = null;
		DestDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Dest(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor> configure)
	{
		DestValue = null;
		DestDescriptor = null;
		DestDescriptorAction = configure;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Headers(Func<FluentDictionary<string, Union<string, ICollection<string>>>, FluentDictionary<string, Union<string, ICollection<string>>>> selector)
	{
		HeadersValue = selector?.Invoke(new FluentDictionary<string, Union<string, ICollection<string>>>());
		return Self;
	}

	/// <summary>
	/// <para>The maximum number of threads to be used by the analysis. Using more<br/>threads may decrease the time necessary to complete the analysis at the<br/>cost of using more CPU. Note that the process may use additional threads<br/>for operational functionality other than the analysis itself.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor MaxNumThreads(int? maxNumThreads)
	{
		MaxNumThreadsValue = maxNumThreads;
		return Self;
	}

	/// <summary>
	/// <para>The approximate maximum amount of memory resources that are permitted for<br/>analytical processing. If your `elasticsearch.yml` file contains an<br/>`xpack.ml.max_model_memory_limit` setting, an error occurs when you try<br/>to create data frame analytics jobs that have `model_memory_limit` values<br/>greater than that setting.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor ModelMemoryLimit(string? modelMemoryLimit)
	{
		ModelMemoryLimitValue = modelMemoryLimit;
		return Self;
	}

	/// <summary>
	/// <para>The configuration of how to source the analysis data.</para>
	/// </summary>
	public PutDataFrameAnalyticsRequestDescriptor Source(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource source)
	{
		SourceDescriptor = null;
		SourceDescriptorAction = null;
		SourceValue = source;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Source(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor descriptor)
	{
		SourceValue = null;
		SourceDescriptorAction = null;
		SourceDescriptor = descriptor;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Source(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor> configure)
	{
		SourceValue = null;
		SourceDescriptor = null;
		SourceDescriptorAction = configure;
		return Self;
	}

	public PutDataFrameAnalyticsRequestDescriptor Version(string? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowLazyStartValue.HasValue)
		{
			writer.WritePropertyName("allow_lazy_start");
			writer.WriteBooleanValue(AllowLazyStartValue.Value);
		}

		if (AnalysisDescriptor is not null)
		{
			writer.WritePropertyName("analysis");
			JsonSerializer.Serialize(writer, AnalysisDescriptor, options);
		}
		else if (AnalysisDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisDescriptor(AnalysisDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("analysis");
			JsonSerializer.Serialize(writer, AnalysisValue, options);
		}

		if (AnalyzedFieldsDescriptor is not null)
		{
			writer.WritePropertyName("analyzed_fields");
			JsonSerializer.Serialize(writer, AnalyzedFieldsDescriptor, options);
		}
		else if (AnalyzedFieldsDescriptorAction is not null)
		{
			writer.WritePropertyName("analyzed_fields");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFieldsDescriptor(AnalyzedFieldsDescriptorAction), options);
		}
		else if (AnalyzedFieldsValue is not null)
		{
			writer.WritePropertyName("analyzed_fields");
			JsonSerializer.Serialize(writer, AnalyzedFieldsValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (DestDescriptor is not null)
		{
			writer.WritePropertyName("dest");
			JsonSerializer.Serialize(writer, DestDescriptor, options);
		}
		else if (DestDescriptorAction is not null)
		{
			writer.WritePropertyName("dest");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestinationDescriptor(DestDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("dest");
			JsonSerializer.Serialize(writer, DestValue, options);
		}

		if (HeadersValue is not null)
		{
			writer.WritePropertyName("headers");
			JsonSerializer.Serialize(writer, HeadersValue, options);
		}

		if (MaxNumThreadsValue.HasValue)
		{
			writer.WritePropertyName("max_num_threads");
			writer.WriteNumberValue(MaxNumThreadsValue.Value);
		}

		if (!string.IsNullOrEmpty(ModelMemoryLimitValue))
		{
			writer.WritePropertyName("model_memory_limit");
			writer.WriteStringValue(ModelMemoryLimitValue);
		}

		if (SourceDescriptor is not null)
		{
			writer.WritePropertyName("source");
			JsonSerializer.Serialize(writer, SourceDescriptor, options);
		}
		else if (SourceDescriptorAction is not null)
		{
			writer.WritePropertyName("source");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSourceDescriptor(SourceDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("source");
			JsonSerializer.Serialize(writer, SourceValue, options);
		}

		if (!string.IsNullOrEmpty(VersionValue))
		{
			writer.WritePropertyName("version");
			writer.WriteStringValue(VersionValue);
		}

		writer.WriteEndObject();
	}
}